package cn.dankal.flyaudio.adapter;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewAdapter;
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewHolder;
import cn.dankal.basiclib.pojo.ProductEntity;
import cn.dankal.flyaudio.R;
import cn.dankal.flyaudio.store.ProductDetailActivity;

public class ClassificationStoreAdapter extends BaseRecyclerViewAdapter<ProductEntity> {


    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_classification_product;
    }

    @Override
    protected BaseRecyclerViewHolder getViewHolder(ViewGroup parent, View rootView, int viewType) {
        return new ViewHolder(rootView);
    }

    public class ViewHolder extends BaseRecyclerViewHolder<ProductEntity> {

        public ViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void onBindData(ProductEntity data, int position) {
            setImageUrl(R.id.iv_img,data.getMainImg());
            setText(R.id.tv_product_name,data.getProductName());
            setText(R.id.tv_product_price,"¥ "+data.getShowPrice());

            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getContext(), ProductDetailActivity.class);
                    intent.putExtra("uuid",data.getUuid());
                    getContext().startActivity(intent);
                }
            });

        }
    }
}
